package server;

import java.io.IOException;
import java.net.URL;

import com.google.gdata.client.GoogleService;
import com.google.gdata.data.Entry;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.util.ServiceException;

public class TestBlogger {
	public static void postBlogger(String email,String passwordemail,String blogid,String blogurl) throws IOException, ServiceException
	{

	    Entry myEntry = new Entry();
		GoogleService myService = new GoogleService("blogger", "exampleCo-exampleApp-1");
		myService.setUserCredentials(email, passwordemail);

		String title = "Test submit content from hatforent";
	    String description = "Test submit content from <a href='http://hatforrent.com'>hatforent</a>";
		
		myEntry.setTitle(new PlainTextConstruct(title));
		myEntry.setContent(new PlainTextConstruct(description));
		
		// Ask the service to insert the new entry
		URL postUrl = new URL("http://www.blogger.com/feeds/"+blogid+"/posts/default");
		myService.insert(postUrl, myEntry);

	}
	
	public static void main(String[] args) {
		try {
			postBlogger("mr.binhkhanh@gmail.com","tuoithantien","4744348736458537667","http://www.lamdep.biz");
		} catch (IOException e) {
			System.out.println(1);
			e.printStackTrace();
		} catch (ServiceException e) {
			// TODO Auto-generated catch block
			System.out.println(2);
			e.printStackTrace();
		}
	}
}
